define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'bill/index' + location.search,
                    add_url: 'bill/add',
                    edit_url: 'bill/edit',
                    del_url: 'bill/del',
                    multi_url: 'bill/multi',
                    import_url: 'bill/import',
                    table: 'bill',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        // {field: 'userId', title: __('Userid'), operate: 'LIKE'},
                        // {field: 'epayCode', title: __('Epaycode'), operate: 'LIKE'},
                        // {field: 'merchantId', title: __('Merchantid'), operate: 'LIKE'},
                        {field: 'traceNo', title: __('Traceno'), operate: 'LIKE'},
                        // {field: 'totalAmt', title: __('Totalamt'), operate:'BETWEEN'},
                        {field: 'input1', title: __('Input1'), operate: 'LIKE'},
                        {field: 'input2', title: __('Input2'), operate: 'LIKE'},
                        {field: 'input3', title: __('Input3'), operate: 'LIKE'},
                        {field: 'input4', title: __('Input4'), operate: 'LIKE'},
                        {field: 'grade', title: __('Grade'), operate: 'LIKE'},
                        { field: 'department', title: __('Department'), operate: 'LIKE' },
                        { field: 'branchCode', title: __('Branchcode'), operate: 'LIKE' },
                        {field: 'classname', title: __('Classname'), operate: 'LIKE'},
                        {field: 'input5', title: __('Input5'), operate: 'LIKE'},
                        {field: 'channel', title: __('Channel'), searchList: {"mbnk":__('Channel mbnk'),"ebnk":__('Channel ebnk'),"open":__('Channel open'),"weixin":__('Channel weixin'),"alipay":__('Channel alipay')}, formatter: Table.api.formatter.normal},

                        {field: 'transDate', title: __('Transdate'), operate: 'LIKE'},
                        {field: 'times', title: __('Times'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'state', title: __('State'), searchList: {"0":__('State 0'),"1":__('State 1'),"2":__('State 2')}, formatter: Table.api.formatter.normal},
                        {field: 'studenntid', title: __('Studenntid'), operate: 'LIKE'},

                        {field: 'mete', title: __('Mete'), operate: 'LIKE'},
                        {field: 'school', title: __('School'), operate: 'LIKE'},


                        // {field: 'transCode', title: __('Transcode'), operate: 'LIKE'},
                        // {field: 'transSeqNum', title: __('Transseqnum'), operate: 'LIKE'},
                        // {field: 'timeStamp', title: __('Timestamp'), operate: 'LIKE'},
                        // 

                        // {field: 'flagDelete', title: __('Flagdelete')},
                        // {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});